<?php
/**
 * 内容目录类
 * @author :zhanghui 
 * @create_date 2008-02-29
 */

class BabyFolder{
	function __construct(){}
	function __destruct(){}
	
	/* 增加目录 
	* @param $conn 数据库连接类
	* @param : array $arr_input - baby_id,menuid,folderid,folder_name,content_cnt,read_open_type
	*/
	function addBabyFolder($conn,$arr_input){
		$str_query = "insert into";
		$str_query .= " baby_folder";
		$str_query .= " set";
		$str_query .= " baby_id={$arr_input['baby_id']}";
		$str_query .= ",menuid={$arr_input['menuid']}";
		$str_query .= ",folder_name={$arr_input['folder_name']}";
		$str_query .= ",read_open_type={$arr_input['read_open_type']}";
		
		$conn->executeQuery($str_query);
	}
	
	/* 删除目录 
	* @param $conn 数据库连接类
	* @param : array $arr_input - baby_id,menuid,folderid,folder_name,content_cnt,read_open_type
	*/
	function deleteBabyFolder($conn,$arr_input){
		$str_query = "delete from";
		$str_query .= " baby_folder";
		$str_query .= " where";
		$str_query .= " baby_id={$arr_input['baby_id']}";
		if(isset($arr_input['menuid'])){
			$str_query .= " and menuid={$arr_input['menuid']}";
		}
		if(isset($arr_input['folderid'])){
			$str_query .= " and folderid={$arr_input['folderid']}";
		}
		
		$conn->executeQuery($str_query);
	}
	
	/* 编辑目录 
	* @param $conn 数据库连接类
	* @param : array $arr_input - baby_id,menuid,folderid,folder_name,content_cnt,read_open_type
	*/
	function editBabyFolder($conn,$arr_input){
		$str_query = "update";
		$str_query .= " baby_folder";
		$str_query .= " set";
		$str_query .= " menuid={$arr_input['menuid']}";
		$str_query .= ",folder_name={$arr_input['folder_name']}";
		$str_query .= ",content_cnt={$arr_input['content_cnt']}";
		$str_query .= ",read_open_type={$arr_input['read_open_type']}";
		
		$conn->executeQuery($str_query);
	}
	
	/* 获取目录 
	* @param $conn 数据库连接类
	* @param : array $arr_input - baby_id,menuid,folderid,folder_name,content_cnt,read_open_type
	* @return : $arr_output
    *			baby_id, 			[0]<br>
    *			menuid, 		    [1]<br>
    *			folderid, 			[2]<br>
    *			folder_name, 		[3]<br>
    *			content_cnt, 		[4]<br>
    *			read_open_type, 	[5]<br>
	*/
	function getBabyFolderList($conn,$arr_input,$limit = null){
		$str_query = "select";
		if(isset($arr_input['cnt'])){
			$str_query .= " count(1)";
		}else{
			$str_query .= " baby_id";
			$str_query .= ",menuid";
			$str_query .= ",folderid";
			$str_query .= ",folder_name";
			$str_query .= ",content_cnt";
			$str_query .= ",read_open_type";
		}
		$str_query .= " baby_folder";
		$str_query .= " where";
		$str_query .= " baby_id={$arr_input['baby_id']}";
		if(isset($arr_input['menuid'])){
			$str_query .= " and menuid={$arr_input['menuid']}";
		}
		if(isset($arr_input['orderby'])){
			$str_query .= " order by {$arr_input['orderby']}";
		}
		if($limit != null){
			$arr_input .= " {$limit}";
		}
		
	$arr_output = $conn->selectQuery($str_query);
	return $arr_output;
	}
		
}	
?>


